import {myAxios} from "./core"

//管理请求
export const http = {
    banner: promise => {
        return myAxios("GET", '/banner', promise)
    },
    getList: promise => {
        return myAxios("GET", '/recommend/appIndex', promise)
    },
    webConfig: promise => {
        return myAxios("GET", '/get/config/system_webConfig', promise)
    },
    login: promise => {
        return myAxios("POST", '/login', promise)
    },
    smsCode: promise => {
        return myAxios("POST", '/smsCode', promise)
    },
    courseBasis: promise => {
        if (promise !== undefined) {
            let url = `/courseBasis?`
            let num = 1;
            for (let it in promise) {
                if (Object.keys(promise).length === num) {
                    url += encodeURIComponent(it) + '=' + promise[encodeURIComponent(it)];
                } else {
                    url += encodeURIComponent(it) + '=' + promise[encodeURIComponent(it)] + '&'
                }
                num++;
            }

            return myAxios("GET", url, promise)
        }

    },
    Classify: promise => {
        return myAxios("GET", '/courseClassify', promise)
    },
// 登录进去用户info接口  头像 用户名 
    userInfo: promise => {
        return myAxios("GET", '/userInfo', promise)
    },
    // 登录进去用户info接口  头像 用户名 我的特色课 一对一辅导  剩余学习币
    getUCenterInfo: promise => {
        return myAxios("GET", '/getUCenterInfo', promise)
    },
    // 讲师的详情页 内容
    teacherDetail: promise => {
        return myAxios("GET", `/teacher/info/${promise}`)
    },
    // 讲师的详情页 头像
    teacherDetailImg: promise => {
        return myAxios("GET", `/teacher/${promise}`)
    },
    // 讲师的详情页 主讲课程
    teacherDetailClass: promise => {
        return myAxios("POST", "/teacher/mainCourse", promise)
    },
    // 讲师的详情页 学员评价
    teacherComment: promise => {
        return myAxios("POST", "/teacher/comment", promise)
    },
    // 讲师的详情页 关注
    teacherFollow: promise => {
        return myAxios("GET", `/teacher/collect/${promise}`)
    },
    // 讲师的详情页 预约时间
    teacherInvite: promise => {
        return myAxios("POST", "/teacher/invite", promise)
    },
    //获取课程详情信息
    basis: promise => {
        return myAxios("GET", `/courseInfo/basis_id=${promise}`)
    },
    //拍照上传文件
    uploadImg: promise => {
        return myAxios("POST", '/public/img', promise)
    },
    //更新头像
    SetInfo: promise => {
        return myAxios("PUT", '/user', promise)
    },
    //获取课程详情信息  评论
    courseComment: promise => {
        return myAxios("POST", "/courseComment", promise)
    },
    //获取课程详情信息 
    courseChapter: promise => {
        return myAxios("POST", "/courseChapter", promise)
    },
    //课程收藏
    collect: promise => {
        return myAxios("POST", "/collect", promise)
    },
    //取消收藏
    cancelCollect: promise => {
        return myAxios("PUT", `/collect/cancel/${promise}`)
    },
    //拿取所有收藏
    collects: promise => {
        let url = '/collect?';

        let num = 1;
        for (let it in promise) {
            if (Object.keys(promise).length === num) {
                url += encodeURIComponent(it) + '=' + promise[encodeURIComponent(it)];
            } else {
                url += encodeURIComponent(it) + '=' + promise[encodeURIComponent(it)] + '&'
            }
            num++;
        }
        return myAxios("GET", url, promise)
    },
    video: promise => {
        return myAxios("GET", `/getPlayToken/video_id=${promise.video}/course_id=${promise.course}`)
    },
    // 约课记录
    otoCourse: promise => {
        return myAxios("GET", "/otoCourse?page=1&limit=10&", promise)
    },
    // 约课记录选择上课时间
    otoCourseOptions: promise => {
        return myAxios("GET", "/otoCourseOptions", promise)
    },
    ///获取地区sonArea
    sonArea: promise => {
        return myAxios("GET", `/sonArea/${promise}`)
    },
    //刷题
    exam: (p, p1) => {
        return myAxios("GET", `/examPoint/${p}/${p1}?`)
    },
    //题库选择
    detailw: promise => {
        return myAxios("GET", '/wap/classify', promise)
    },
    //题库选择
    ques: promise => {
        return myAxios("GET", `/wap/quesBank/${promise}?`)
    },
    //刷题类型
    point: promise => {
        return myAxios("GET", `/point/info/${promise}`)
    },
    //题目
    examPoint: promise => {
        return myAxios("GET", `/examPoint/questions/${promise.id}/${promise.num}`)
    }
}
